// Decompiled on 周六 2月 22 19:31:49 CST 2025 with Zomboid Decompiler v0.1.3 using Vineflower.
package zombie.core.skinnedmodel.visual;

import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import zombie.core.skinnedmodel.population.ClothingItem;

public final class ItemVisuals extends ArrayList<ItemVisual> {
    public void save(ByteBuffer output) throws IOException {
        output.putShort((short)this.size());

        for (int _int = 0; _int < this.size(); _int++) {
            ((ItemVisual)this.get(_int)).save(output);
        }
    }

    public void load(ByteBuffer input, int WorldVersion) throws IOException {
        this.clear();
        short _short = input.getShort();

        for (int _int = 0; _int < _short; _int++) {
            ItemVisual itemVisual = new ItemVisual();
            itemVisual.load(input, WorldVersion);
            this.add(itemVisual);
        }
    }

    public ItemVisual findHat() {
        for (int _int = 0; _int < this.size(); _int++) {
            ItemVisual itemVisual = (ItemVisual)this.get(_int);
            ClothingItem clothingItem = itemVisual.getClothingItem();
            if (clothingItem != null && clothingItem.isHat()) {
                return itemVisual;
            }
        }

        return null;
    }

    public ItemVisual findMask() {
        for (int _int = 0; _int < this.size(); _int++) {
            ItemVisual itemVisual = (ItemVisual)this.get(_int);
            ClothingItem clothingItem = itemVisual.getClothingItem();
            if (clothingItem != null && clothingItem.isMask()) {
                return itemVisual;
            }
        }

        return null;
    }
}
